package Undefinied;


import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.AbstractComponent;
import org.newdawn.slick.gui.ComponentListener;
import org.newdawn.slick.gui.TextField;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import Components.Player;

 
public class  TestState extends BasicGameState {
    int stateID = -1;
    Player test;
    ArrayList <Anzeigbar> Liste=new ArrayList <Anzeigbar>();
    
    TestState( int stateID ){
       this.stateID = stateID;
    }
 
    @Override
    public int getID() {
        return stateID;
    }
    
    public void init(GameContainer gc, final StateBasedGame sbg)throws SlickException {
  	    
    	System.out.println("Playerstate Initialisiet");
	
    	test = new Player(221);
    	test.init(gc, sbg);
    	gc.getGraphics().setBackground(Color.red);

    }
    
    public void enter(GameContainer gc, StateBasedGame sbg)throws SlickException {
		
	    System.out.println("Playerstate entered");
    }
 
    
    public  void leave(GameContainer container,StateBasedGame game)throws SlickException{
    }
    
    public synchronized void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {	
	test.render(gc, sbg, g);
    }
    
 
    public void update(GameContainer container, StateBasedGame sbg, int delta) throws SlickException {
	
	test.update(container, sbg, delta);
	
	
	
	
	
	test.update(container, sbg, delta);
  	Input input = container.getInput(); 
  	
  	int x=input.getMouseX();
 	int y=input.getMouseY();
 	int xp;
 	int yp;
 	
 	for (Anzeigbar entry : Liste) {
 		if(entry.MouseOver(x,y)){
			xp=(int)(x-entry.XPos);
 			yp=(int)(y-entry.YPos);
 			if(input.isMousePressed(0)){
 				entry.mousePressed(0,xp , yp);
 			}
 			if(input.isMousePressed(2)){
 				entry.mousePressed(2,xp , yp);
 			}
 		}
 	}
 	
     	
    }
    
    


}



